/*
 * @Autor: dc
 * @Date: 2022-03-18 17:46:44
 * @LastEditors: dc
 * @LastEditTime: 2022-03-29 15:34:57
 * @Description: 
 */
import React, { Component } from 'react';
// import axios from "axios"
import { withRouter } from 'react-router-dom'
// 订阅消息
class Header extends Component {

    back = ()=>{
        // 后退
        this.props.history.goBack();
    }
    
    forward = ()=>{
        // 前进
        this.props.history.goForward();
    }

    go = ()=>{
        // 后退 2格
        this.props.history.go(-2);
    }


    render() {
        console.log('Header的组件收到的props',this.props)
        return (
            <div>
                <h2>React Router Demo</h2>
                <button onClick={this.back}>回退</button>
                <button onClick={this.forward}>前进</button>
                <button onClick={this.go}>go</button>
            </div>
        );
    }
}


// withRouter 可以加工一般组件,让一般组件具备路由组件所特有的API;
// wutgRouter 的返回值是一个新组件;
export default withRouter(Header);